package windbell.domain.risk.impl;

import edu.fudan.mylang.pf.query.HQLBasedPagedQueryCriteria;
import java.util.Date;
import org.hibernate.Query;
import windbell.domain.risk.RiskLevel;
import windbell.domain.risk.RiskReport;
import windbell.domain.risk.RiskReportStatCriteria;
import windbell.domain.risk.RiskReportStatus;

public class RiskReportStatCriteriaImpl extends HQLBasedPagedQueryCriteria<RiskReport> implements RiskReportStatCriteria {
  private RiskLevel riskLevel;
  
  public RiskLevel getRiskLevel() {
    return this.riskLevel;
  }
  
  public RiskReportStatCriteria setRiskLevel(final RiskLevel riskLevel) {
    this.riskLevel = riskLevel;
    return this;			
    
  }
  
  private RiskReportStatus status;
  
  public RiskReportStatus getStatus() {
    return this.status;
  }
  
  public RiskReportStatCriteria setStatus(final RiskReportStatus status) {
    this.status = status;
    return this;			
    
  }
  
  private RiskReportStatus fixedStatus;
  
  public RiskReportStatus getFixedStatus() {
    return this.fixedStatus;
  }
  
  public RiskReportStatCriteria setFixedStatus(final RiskReportStatus fixedStatus) {
    this.fixedStatus = fixedStatus;
    return this;			
    
  }
  
  private Date endDueDate;
  
  public Date getEndDueDate() {
    return this.endDueDate;
  }
  
  public RiskReportStatCriteria setEndDueDate(final Date endDueDate) {
    this.endDueDate = endDueDate;
    return this;			
    
  }
  
  private Date foundStartDate;
  
  public Date getFoundStartDate() {
    return this.foundStartDate;
  }
  
  public RiskReportStatCriteria setFoundStartDate(final Date foundStartDate) {
    this.foundStartDate = foundStartDate;
    return this;			
    
  }
  
  private Date foundEndDate;
  
  public Date getFoundEndDate() {
    return this.foundEndDate;
  }
  
  public RiskReportStatCriteria setFoundEndDate(final Date foundEndDate) {
    this.foundEndDate = foundEndDate;
    return this;			
    
  }
  
  protected String buildHQLFrom() {
    return " from windbell.domain.risk.impl.RiskReportImpl this  left join  this.riskCheckItem.riskCheck.checkTarget as target ";
  }
  
  protected String buildHQLBody() {
    String hql = "where 1 = 1 ";
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getRiskLevel()) ){
    	hql += " and ((this.riskLevel) = (:riskLevel))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getStatus()) ){
    	hql += " and ((this.Status) = (:status))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getEndDueDate()) ){
    	hql += " and ((this.dueDate) < (:endDueDate))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getFoundStartDate()) ){
    	hql += " and ((this.foundDate) > (:foundStartDate))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getFoundEndDate()) ){
    	hql += " and ((this.foundDate) < (:foundEndDate))" ;
    }
    return hql;
    
  }
  
  public void initOrderBys() {
    
  }
  
  protected void fillParameter(final Query query) {
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getRiskLevel())){
    	query.setParameter("riskLevel",getRiskLevel()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getStatus())){
    	query.setParameter("status",getStatus()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getFixedStatus())){
    	query.setParameter("fixedStatus",getFixedStatus()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getEndDueDate())){
    	query.setParameter("endDueDate",getEndDueDate()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getFoundStartDate())){
    	query.setParameter("foundStartDate",getFoundStartDate()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getFoundEndDate())){
    	query.setParameter("foundEndDate",getFoundEndDate()) ;
    }			
    
  }
  
  protected Boolean isDistinct() {
    return true;
  }
  
  public RiskReportStatCriteriaImpl() {
    initOrderBys();
  }
}
